/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

/* Main container - responsive height for iframe vs full screen */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Detect if not in iframe and adjust height */
@media screen and (min-height: 500px) {
    body:not(.in-iframe) .container {
        height: 90vh;
        padding: 20px;
    }
}

/* Legend panel - compact design for iframe */
.legend-panel {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #333;
}

.legend-color.oxygenated {
    background: #e74c3c;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
}

.legend-color.deoxygenated {
    background: #4a90e2;
    box-shadow: 0 0 8px rgba(74, 144, 226, 0.5);
}

/* Main circulation container */
.circulation-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.circulation-diagram {
    width: 100%;
    max-width: 400px;
    height: auto;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 10px;
}

/* Blood vessel styling with animation effects */
.blood-vessel {
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.blood-vessel:hover {
    stroke-width: 10;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Heart styling with pulse animation */
.heart-shape {
    animation: heartbeat 2s infinite ease-in-out;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Blood cell animations */
.blood-cell {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.oxy-cell {
    animation: pulse-red 1s infinite alternate;
}

.deoxy-cell {
    animation: pulse-blue 1s infinite alternate;
}

@keyframes pulse-red {
    0% { fill: #e74c3c; }
    100% { fill: #c0392b; }
}

@keyframes pulse-blue {
    0% { fill: #4a90e2; }
    100% { fill: #2980b9; }
}

/* Control panel - optimized for iframe */
.control-panel {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 36px; /* Touch-friendly height */
    min-width: 80px;
    white-space: nowrap;
}

.control-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.control-btn.secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Information panel - collapsible for space efficiency */
.info-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-height: 120px;
    overflow-y: auto;
}

.info-panel h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #2c3e50;
    text-align: center;
}

.step {
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.3;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.step.active {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
    font-weight: 600;
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Responsive design for mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .legend-panel {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    
    .legend-item {
        font-size: 11px;
    }
    
    .control-panel {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .control-btn {
        flex: 1;
        min-width: 70px;
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .info-panel {
        max-height: 100px;
    }
    
    .step {
        font-size: 10px;
    }
}

/* Animation states */
.paused .blood-cell animateMotion,
.paused .heart-shape {
    animation-play-state: paused;
}

.stopped .blood-cell {
    display: none;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .blood-cell animateMotion,
    .heart-shape,
    .oxy-cell,
    .deoxy-cell {
        animation: none;
    }
    
    .control-btn:hover {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .container {
        background: white;
        border: 2px solid black;
    }
    
    .legend-color.oxygenated {
        background: #cc0000;
    }
    
    .legend-color.deoxygenated {
        background: #0066cc;
    }
}